package main

import (
	log "github.com/sirupsen/logrus"
	"os"
)

func main() {
	//log.WithFields(log.Fields{"animal": "dog"}).Info("一条舔狗出现了")
	//log.WithFields(log.Fields{
	//	"event": event,
	//	"topic": topic,
	//	"key": key,
	//}).Fatal("Failed to send event")
	//log.Trace("Something very low level.")
	//log.Debug("Useful debugging information.")
	//log.Info("Something noteworthy happened!")
	//log.Warn("You should probably take a look at this.")
	//log.Error("Something failed but I'm not quitting.")
	//// 记完日志后会调用os.Exit(1)
	//log.Fatal("Bye.")
	//// 记完日志后会调用 panic()
	//log.Panic("I'm bailing.")

	demo2()
}
func demo1() {
	var logobj = log.New()
	logobj.Out = os.Stdout
	// 可以设置像文件等任意`io.Writer`类型作为日志输出
	// file, err := os.OpenFile("logrus.log", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
	// if err == nil {
	//  log.Out = file
	// } else {
	//  log.Info("Failed to log to file, using default stderr")
	// }
	// 会记录info及以上级别 (warn, error, fatal, panic)
	logobj.SetLevel(log.InfoLevel)
	logobj.WithFields(log.Fields{"animal": "dog", "size": 10}).Info("一群舔狗出现了")
}
func demo2() {
	log.SetReportCaller(true)
	logg := log.WithFields(log.Fields{"user": "ybl", "id": 123})
	logg.Info("something happened on that request")
	logg.Info("something happened ")
}
